﻿#ifndef __SS_WIN32_MSG_H__
#define __SS_WIN32_MSG_H__
#include <windows.h>

namespace StarSeeker
{

class ssWin32Message
{
public:
	bool RouteMessage(int id, WPARAM wParam, LPARAM lParam);
protected:
	virtual void OnClose()=0;
	virtual void OnLButtonDown(int x, int y, unsigned int state)=0;
	virtual void OnRButtonDown(int x, int y, unsigned int state)=0;
	virtual void OnKeyDown(unsigned int key)=0;
	virtual void OnMouseMove(int x, int y, unsigned int state)=0;
	virtual void OnMouseWheel(short wheel, unsigned int state)=0;
};

inline bool ssWin32Message::RouteMessage(int id, WPARAM wParam, LPARAM lParam)
{
	switch(id)
	{
	case WM_CLOSE:
		OnClose();
		return true;
	case WM_LBUTTONDOWN:
		OnLButtonDown((lParam<<16)>>16, lParam>>16, wParam);
		return true;
	case WM_RBUTTONDOWN:
		OnRButtonDown((lParam<<16)>>16, lParam>>16, wParam);
		return true;
	case WM_MOUSEMOVE:
		OnMouseMove((lParam<<16)>>16, lParam>>16, wParam);
		return true;
	case WM_MOUSEWHEEL:
		OnMouseWheel(wParam>>16, (wParam<<16)>>16);
		return true;
	case WM_KEYDOWN:
		OnKeyDown(wParam);
		return true;
	}
	return false;
}

}
#endif
